﻿using System;
using System.Text;
using Telerik.Web.UI;

public partial class ltMan_messages_messageList : AdminBasePage
{
    ltModel.BLL.message msg = new ltModel.BLL.message();

    protected void Page_Load(object sender, EventArgs e)
    {
        SqlPager pager = new SqlPager("lt_message", "id", "*");
        StringBuilder where = new StringBuilder();
        if (!string.IsNullOrEmpty(sName.Text))
        {
            where.AppendFormat(" title like '%{0}%'", sName.Text.Replace("'", "''"));
        }
        string ws = Request.QueryString["ws"];
        if (ws == "1")
        {
            if (where.Length > 0)
                where.Append(" and ");
            where.AppendFormat(" zt=0 ");
        }
        pager.Where = where.ToString();
        pager.OrderBy = "addtime desc";
        RadGridBinder.Create(RadGrid1, pager);
    }
    protected void RadGrid1_DeleteCommand(object sender, GridCommandEventArgs e)
    {
        int id = int.Parse(GridCommander.ExtractValue(e, "id"));
        OperateLog.AddSuccessLog(CurrentUser.user_id, Request.UserHostAddress, "在线留言-删除>" + msg.GetModel(id).title);
        msg.Delete(id);
    }
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == "Verify")
        {
            string ids = GridCommander.JoinValues(e.Item.OwnerTableView.DataKeyValues, RadGrid1.SelectedIndexes);
            msg.UpdateZT(ids, e.CommandArgument.ToString());
            OperateLog.AddSuccessLog(CurrentUser.user_id, Request.UserHostAddress, "在线留言-修改审核>" + ids);
            RadGrid1.Rebind();
        }
        else if (e.CommandName == "Public")
        {
            string ids = GridCommander.JoinValues(e.Item.OwnerTableView.DataKeyValues, RadGrid1.SelectedIndexes);
            msg.UpdatePublic(ids, e.CommandArgument.ToString());
            OperateLog.AddSuccessLog(CurrentUser.user_id, Request.UserHostAddress, "在线留言-修改公开>" + ids);
            RadGrid1.Rebind();
        }
    }
    protected void b1_Click(object sender, EventArgs e)
    {
        RadGrid1.Rebind();
    }
}